 #{extends 'main.html' /}
 #{ifErrors} ${error} #{/ifErrors}
<script type="text/javascript"> 
var x = new Array();
//var e=document.getElementById('state');
//var dropdown=e.options[e.selectedIndex].value;
function postToServer()
{
	$.post('@{ideaUpdate2()}' ,{ideaIds:x},function(){
			window.location.reload();
		});

	
}

</script> 
#{ifnot isBlocked}

<h1> ${t.title}  </h1> 
<h3>  ${t.content} </h3>
 <br><br>
 <a href="@{Application.RelationBetweenTopics(t.id, d.id)}"> Set
 Relation </a> </br>
	 #{ifnot t.ideas}
	 <br>
	 <a href = "@{Application.deleteTopic(t.id, d.id)}">Delete Topic</a>
	 #{/ifnot}

	 <br>
	 <a href = "@{Application.blockTopic(t.id)}">User Restrictions</a> 
	 <br>

	 
<a href = "@{Application.createIdea(t.id,d.id)}">create new Idea/Draft</a><br>
  ${t.content} 

#{if isOrganizer=true}
#{if t.isLocked==true}
<h1>State: Locked</h1>
<a href="@{Application.unlockTopic(t.id)}"> Unlock Topic </a>
#{/if}
#{if t.isLocked==false}
<h1>State: Unlocked</h1>
<a href="@{Application.lockTopic(t.id)}"> Lock Topic </a>
#{/if}
#{/if}

 <br><br>
 #{ifnot isFollowing}
 <a href="@{Application.followTopic(t.id)}"onclick="alert('You are now following the Topic successfully');">Follow </a> #{/ifnot}|
 <a href="@{Application.RelationBetweenTopics(t.id, d.id)}"> Set
 Relation </a> </br>
	 #{ifnot t.ideas}
	 <a href = "@{Application.deleteTopic(t.id, d.id)}">Delete Topic</a>
	 #{/ifnot}
	 <br>
<a href = "@{Application.createIdea(t.id,d.id)}">create new Idea/Draft</a>
<br>
#{if !IdeaDeveloper}
<br><a href = "@{Application.requestedMirg()}">requested mirgins</a><br/>
#{/if}
	 <br>
<h1>the Ideas</h1>	 
<form action="@{Application.ideaUpdate2(t.id,d.id)}" method="get">	 
#{if t.ideas}
<table style="width: 83%" align="center" border="1" cellspacing="0">
	<tr>
		<th></th>
		<th>Title</th>
		<th>author</th>
		<th>views</th>
		<th>comments</th>
		<th>Average Rating</th>
		<th>state</th>
		
	</tr>
#{list items: t.ideas, as:'idea'}
	<tr>
		<td><input type="checkbox" name="check" value="${idea.id}" /></td>
		<td><a href = "@{Application.IdeaView(idea.id,t.id,d.id)}"> ${idea.title}</a></td>
		<td>${idea.author.nickName}</td>
		<td>${idea.views}</td>
		<td>${idea.comments.size()}</td>
		<td>${idea.averageRate()} &nbsp;&nbsp;&nbsp; By ${idea.rate.size()}&nbsp; Users</td>
		<td>
		#{if idea.state==1}
		 opened
		 #{/if}
	    #{if idea.state==2}
	    Closed
	    #{/if}
	    #{if idea.state==3}
	    Promoted to execution
	    #{/if}
	    #{if idea.state==4}
	    Hidden
	    #{/if}
	    </td>	
</tr>
#{/list}
</table>	    
<br/>
<br/>

<select name="state" id="state">
#{if roleIsIdeaDeveloper==false}
         <option value="0" selected="selected">please select</option>
		<option value="1">opened</option>
		

		<option value="2">close</option>
		<option value="3">promote to execution</option>
	    <option value="4">Hide</option>
		<option value="5">Delete</option>
		<option value="6">Mirg</option>
#{/if}
#{if roleIsIdeaDeveloper==true}
		<option value="7">Request mirging</option>
#{/if}		
	   </select>&nbsp;&nbsp;&nbsp;
 <input type="submit" value="Apply" />
  
  <select name="label" id="label">
 #{if user.labels}
 <option value="0" selected="selected">please select</option>
 #{list user.labels, as:'label'}
 <option value="${label.id}">${label.titel}</option>
#{/list}
 #{/if}
  <input type="submit" value="Add" />
 
#{/if}
#{else}
No Ideas in ${t.title} Topic !!
#{/else}
</form>
 <br><br>
 #{/ifnot}
 #{else}
 Sorry You Are Not Authorized to view/edit this Topic.
<br>
 #{/else}



<a href = "@{Application.viewDepartment(d.id)}">Back to ${d.name}</a>